#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
struct node{
	int begin;
	int end;
	int time;
}game[10005];
bool cmp(node x,node y)
{
	return x.end<y.end;
}
int ans=0;
int end1=-1;
int main()
{
	int n;
	scanf("%d",&n);
	for (int i=0;i<=n-1;i++)
	{
		scanf("%d %d",&game[i].begin,&game[i].end);
		game[i].time=game[i].end-game[i].begin;
	}
	sort(game,game+n,cmp);
	for (int i=0;i<=n-1;i++)
	{
		if (game[i].begin>=end1)
		{
			end1=game[i].end;
			ans++;
		}
	}
	printf("%d",ans);
	
	
	
	return 0;
}
